<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/static/include/taglib.jsp"%>

<!DOCTYPE html>
<html>
<head>
    <title>商品规格</title>

    <script src="${path}/static/js/product/typeProps.js" type="text/javascript"></script>
</head>

<body>
<!-- <div class="modal-content"> -->
<form id="inputForm" modelAttribute="specification" action="${ctx}/product/goodsType/saveTypeProps" method="post" class="form-horizontal">
    <!-- modal head -->
    <div class="modal-header">
        <button class="close" type="button" data-dismiss="modal">×</button>
        <h4 class="modal-title" id="viewModalLabel">修改（${type.name }）属性</h4>
    </div>
    <!-- modal content -->
    <div class="modal-body">
        <!-- error message here -->
        <div id="messageBox" class="alert alert-warning hide"></div>
        <tags:message content="${message}"/>
        
        <button class="btn btn-default btn-sm" type="button" id="propAddBtn"><i class="glyphicon glyphicon-plus"> 增加</i></button>
        <button class="btn btn-default btn-sm" type="button" id="propRestBtn"><i class="glyphicon glyphicon-minus"> 还原</i> </button>
        
        <div class="tab-content">
            <%-- dynamic tab --%>
            <!-- <div class="panel-body"> -->
                <table id="props_table" class="table table-striped table-bordered table-hover dataTable">
                    <thead>
                    <tr>
                        <%-- dynamic table header --%>
                        <!-- <th width="50px">序号</th> -->
                        <%--主键不输出--%>
                        <th width="120px">属性名</th>
                        <th width="150px">类型</th>
                        <th>选择项(逗号分隔)</th>
                        <th width="100px">单位</th>
                        <th width="80px">必填</th>
                        <th width="80px">校验</th>
                        <th width="50px" title="需要删除时勾选">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                        <%-- dynamic table content --%>
                        <c:forEach items="${attributes }" var="attr" varStatus="status">
                        <tr>
					       <td><input type="text" name="attributes[${status.index }].name"  maxlength="60" class="form-control required" value="${attr. name}"/></td>
					       <td>
						   <select name="attributes[${status.index }].type" class="form-control">
						   
						   <optgroup label="输入项">
						   	<option value="1" <c:if test="${attr. type eq 1}">selected</c:if>>输入项 可搜索 </option>
							<option value="2" <c:if test="${attr. type eq 2}">selected</c:if>>输入项 不可搜索 </option>
							</optgroup> 	
					
							<optgroup label="选择项">
						   	<option value="3" <c:if test="${attr. type eq 3}">selected</c:if>>选择项 可搜索 </option>
							<option value="4" <c:if test="${attr. type eq 4}">selected</c:if>>选择项 不可搜索 </option>
							</optgroup>
							
						   </select>
						   </td>
					       <td><input type="text" name="attributes[${status.index }].options"  class="form-control" value="${attr. options}"/></td>
					       <td><input type="text" name="attributes[${status.index }].unit" class="form-control" value="${attr. unit}"/></td>
						   <td>
						       <select name="attributes[${status.index }].required" class="form-control">
							       	<option value="0" <c:if test="${attr. required eq 0}">selected</c:if>>否</option>
							       	<option value="1" <c:if test="${attr. required eq 1}">selected</c:if>>是</option>		       	
						       </select>
						   </td>
						        
					       <td>
						       <select name="attributes[${status.index }].datatype" class="form-control">
							       	<option value="">无</option>
							       	<option value="int" <c:if test="${attr. datatype eq 'int'}">selected</c:if>>整数</option>
							       	<option value="float" <c:if test="${attr. datatype eq 'float'}">selected</c:if>>浮点数</option>
						       </select>
						   </td>
					       <td ><a href="javascript:;" class="delete">
								<span class="glyphicon glyphicon-trash"></span></a>
							</td>
						</tr>
                        </c:forEach>
                    </tbody>
                </table>
            </div>
            <input type="hidden" id="id" name="id" value="${param.id}" />
        </div>
        <!-- modal foot -->
        <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            <button type="submit" class="btn btn-primary">提交更改</button>
        </div>
</form>
<!-- </div> -->

<!-- template -->
<table style="display:none">
	<tr id="propTemplate">
	      <td><input type="text" name="attributes[0].name"  maxlength="60" class="form-control required" value=""/></td>
	      <td>
		   <select name="attributes[0].type" class="form-control">
		   
		   <optgroup label="输入项">
		   	<option value="1">输入项 可搜索 </option>
			<option value="2">输入项 不可搜索 </option>
			</optgroup> 	
		
			<optgroup label="选择项">
		   	<option value="3">选择项 可搜索 </option>
			<option value="4">选择项 不可搜索 </option>
			</optgroup>
			
		   </select>
	   </td>
	      <td><input type="text" name="attributes[0].options"  class="form-control" value=""/></td>
	      <td><input type="text" name="attributes[0].unit" class="form-control" value=""/></td>
	   <td>
	       <select name="attributes[0].required" class="form-control">
		       	<option value="0">否</option>
		       	<option value="1">是</option>		       	
	       </select>
	   </td>
	        
	    <td>
	       <select name="attributes[0].datatype" class="form-control">
		       	<option value="">无</option>
		       	<option value="int">整数</option>
		       	<option value="float">浮点数</option>
	       </select>
	   </td>
	   <td><a href="javascript:;" class="delete"><span class="glyphicon glyphicon-trash"></span></a></td>
	</tr>
</table>
</body>
</html>
